package com.wqr.consumer;

import com.wqr.api.pojo.User;
import com.wqr.api.service.IUserService;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * @author LTX
 */
@RestController
public class ConsumerController {

    ///    同一台机器运行provider和consumer，需要禁止单播改为广播，添加parameters = {"unicast", "false"}
    //@Reference(version = "1.0.0", parameters = {"unicast", "false"})
    @Reference(version = "1.0.0")
    private IUserService userService;

    @GetMapping("/hello/{id}")
    public String doSayHello(@PathVariable Integer id) {
        User user = userService.selectUserById(id);
        return user.getUserName();
    }
}
